package com.example.spark.rdd;

import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;

import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;

public class SparkRDDExample_3 {
    public static void main(String[] args) {

        //创建配置对象
        SparkConf conf = new SparkConf();
        conf.setMaster("local[*]");
        conf.setAppName("spark_demo");

        //创建SparkContext
        JavaSparkContext jsc = new JavaSparkContext(conf);
        //编写逻辑代码

        List<String> datas = Arrays.asList("Java", "Python", "C", "C#", "PHP");
        JavaRDD<String> rdd = jsc.parallelize(datas, 2);
        rdd.saveAsTextFile("output");
        //关闭,回收资源
        jsc.stop();


    }



}
